<?php

header('Content-Type:text/html;charset=utf-8');
@$a=$_POST['zh'];
@$b=$_POST['ymm'];
@$c=$_POST['xmm'];



$PDO=new PDO('mysql:dbname=diancan;charset=UTF8;','root');

$sou=$PDO->prepare('select * from user');
$sou->execute();
$cc=$sou->fetchAll(PDO::FETCH_NAMED);

$aa=$cc[0]['userName'];
$bb=$cc[0]['password'];
foreach ($cc as $key => $value) {
	if($value['userName']==$a){
		if ($value['password']==$b) {
			$ss=$PDO->prepare('update user set password=:aa where userName=:bb');
			$ss->execute(array('aa'=>$c,'bb'=>$a));
			echo "恭喜你，修改密码成功！";
			header('Refresh:2;url=diancan.php');
		}else{
			echo "密码重复!";
			header('Refresh:2;url=diancan.php');
		}
	}else{
		echo "账号不存在!";
		header('Refresh:2;url=diancan.php');
	}
}


?>